/**
 * index
 */
layui.use(['jquery', 'layer', 'miniAdmin','miniTongji'], function () {
    let $ = layui.jquery,
        layer = layui.layer,
        miniAdmin = layui.miniAdmin;
    let u=localStorage.getItem("a@m");
    let loginU={};
    if(u==undefined){
        layer.msg('请登录', {
            icon: 1,
            time: 500
        },function () {
            window.location = 'logout';
        });
    }else{
        loginU=decryptLocalStorage(u);
        let adminName="【教师账号】"
        if(loginU.userType=='system'){
            adminName="【超级管理员】"
        }else if(loginU.userType=='nation'){
            adminName="【国家账号】"
        }else if(loginU.userType=='province'){
            adminName=loginU.provinceName+"【省级账号】"
        }else if(loginU.userType=='city'){
            adminName=loginU.cityName+"【市级账号】"
        }else if(loginU.userType=='district'){
            adminName=loginU.districtName+"【区级账号】"
        }else if(loginU.userType=='school'){
            adminName="【学校账号】";
        }else if(loginU.userType=='teacher'){
            adminName="【教师账号】"
        }
        adminName=adminName+loginU.trueName;
        $('#adminName').text(adminName);
    }
    /** set time **/
    setInterval(function(){
        checkLogin(layer);
    },1000*60*1);
    var options = {
        iniUrl: "admin/v1/init?token="+loginU.token,    // 初始化接口
        clearUrl: "api/clear.json", // 缓存清理接口
        urlHashLocation: true,      // 是否打开hash定位
        bgColorDefault: false,      // 主题默认配置
        multiModule: true,          // 是否开启多模块
        menuChildOpen: false,       // 是否默认展开菜单
        loadingTime: 0,             // 初始化加载时间
        pageAnim: true,             // iframe窗口动画
        maxTabNum: 20,              // 最大的tab打开数量
    };
    miniAdmin.render(options);

    $('.login-out').on("click", function () {
        layer.msg('退出登录成功', {
            icon: 1,
            time: 500
        },function () {
            window.location = 'logout';
        });
    });
});